package com.javaAdmin.model;

import com.javaAdmin.validate.Save;
import com.javaAdmin.validate.Update;
import org.hibernate.validator.constraints.Length;

import javax.validation.Validation;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @author Administrator
 */
public class Student {

    @NotNull(groups = Update.class)
    private int id;

    @NotBlank(message = "姓名不能为空", groups = {Save.class, Update.class})
    @Length(max = 5, message = "姓名不能超过5个字符", groups = {Save.class, Update.class})
    private String name;

    @NotNull(groups = Save.class)
    @Min(value = 6, groups = Save.class)
    @Max(value = 25, groups = Save.class)
    private Integer age;


    private Integer sex;
    private Date createTime;
    private Date updateTime;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", sex=" + sex +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}
